<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__STATIC__/admin/css/pintuer.css">
<link rel="stylesheet" href="__STATIC__/admin/css/admin.css">
<script src="__STATIC__/admin/js/jquery.js"></script>
<script src="__STATIC__/admin/js/pintuer.js"></script>
<script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container');
</script>  

<!-- 动态增减input框 -->
<script>  
$(document).ready(function() {  
  
var MaxInputs       = 9; //maximum input boxes allowed  最大允许输入框
var InputsWrapper   = $("#InputsWrapper"); //Input boxes wrapper ID  输入框包装ID
var AddButton       = $("#AddMoreFileBox"); //Add button ID  添加按钮ID
  
var x = InputsWrapper.length; //initlal text box count  initlal文本框计算
var FieldCount=1; //to keep track of text box added  跟踪添加的文本框
  
$(AddButton).click(function (e)  //on add input button click  在添加输入按钮上单击
{  
        if(x <= MaxInputs) //max input box allowed  最大允许输入框
        {  
            FieldCount++; //text box added increment  文本框添加增量
            //add input box  添加输入框
            $(InputsWrapper).append('<div style="clear:left;"><input type="file" id="field_'+ FieldCount +'1" name="bigpic[]" class="input tips" style="width:25%; float: left; margin-bottom: 10px;"  value=""  data-toggle="hover" data-place="right" data-image="" /><input type="text" class="input w50" value="" name="alt[]" style="margin-left: 10px; margin-top: 3px;" /><button class="button bg-blue margin-left icon-minus removeclass" style="margin-top: 3px;"></button></div>');  
            x++; //text box increment  文本框增加
        }  
return false;  
});  
  
$("body").on("click",".removeclass", function(e){ //user click on remove text  用户点击删除文本。
        if( x > 1 ) {  
                $(this).parent('div').remove(); //remove text box  删除文本框
                x--; //decrement textbox  减量文本框
        }  
return false;  
})   
  
});  
</script>  
</head>
<body>
<form method="post" action="{:url('Category/search')}">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li> <a class="button border-main icon-plus-square-o" href="add.html"> 添加内容</a> </li>
        <li>搜索：</li>
        <li>首页
          <select name="ishome" class="input" onchange="changesearch()" style="width:60px; line-height:17px; display:inline-block">
            <option value="">选择</option>
            <option value="1">是</option>
            <option value="">否</option>
          </select>
          &nbsp;&nbsp;
          推荐
          <select name="isvouch" class="input" onchange="changesearch()"  style="width:60px; line-height:17px;display:inline-block">
            <option value="">选择</option>
            <option value="2">是</option>
            <option value="">否</option>
          </select>
          &nbsp;&nbsp;
          置顶
          <select name="istop" class="input" onchange="changesearch()"  style="width:60px; line-height:17px;display:inline-block">
            <option value="">选择</option>
            <option value="3">是</option>
            <option value="">否</option>
          </select>
        </li>
        <li>
          <select name="cateid" class="input" style="width:200px; line-height:17px;" onchange="changesearch()">
            <option value="">请选择分类</option>
            {volist name='cate' id='category'}
              <option value="{$category.cateid}">
                <?php 
                  if($category['parentsid']!==0){echo "|".str_repeat('-',$category['level']*4);} 
                ?>
                {$category.name}
              </option>
            {/volist}
          </select>
        </li>
        <li>
          <input type="text" placeholder="请输入搜索关键字" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <button class="button border-main icon-search" type="submit">搜索</button>
        </li>
      </ul>
    </div>
    </form>
    <form method="post" action="" id="listform" name="listform">
    <table class="table table-hover text-center">
      <tr>
        <th width="8%" style="text-align:left; padding-left:20px;">ID</th>
        <th width="7%">排序</th>
        <th width="10%">图片</th>
        <th width="30%">名称</th>
        <th width="10%">属性</th>
        <th width="15%">分类名称</th>
        <th width="20%">操作</th>
      </tr>
      {volist name='list' id='list' empty='暂时没有数据'}
        <tr>
          <td style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="{$list.id}" />
           {$list.id}</td>
          <td><input type="text" name="picsort[]" value="{$list.picsort}" style="width:50px; text-align:center; border:1px solid #ddd; padding:7px 0;" /></td>
          <td width="10%"><img src="{$list.smallpic}" alt="" width="70" height="50" /></td>
          <td>{$list.titlename}</td>
          <td>
            <font color="#00CC99">
              {if condition="strpbrk($list.position,'1')"}
              首页
              {/if}
              {if condition="strpbrk($list.position,'2')"}
              推荐
              {/if}
              {if condition="strpbrk($list.position,'3')"}
              置顶
              {/if}
              {if condition="(!strpbrk($list.position,'1')) AND (!strpbrk($list.position,'2')) AND (!strpbrk($list.position,'3'))"}
              无
              {/if}
            </font>
          </td>
          <td>{$list.name}</td>
          <td>
            <div class="button-group"> 
              <a class="button border-main" href="{:url('Category/edit',array('id' => $list.id))}">
                <span class="icon-edit"></span> 修改
              </a> 
              <a class="button border-red" href="javascript:void(0)" onclick="return del({$list.id})">
                <span class="icon-trash-o"></span> 删除
              </a> 
            </div>
          </td>
        </tr> 
      {/volist}   
      <tr>
        <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="7" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> <a href="javascript:void(0)" style="padding:5px 15px; margin:0 10px;" class="button border-blue icon-edit" onclick="sorts()"> 排序</a> 批量操作：
          <select name="ishome" style="padding:5px 15px; border:1px solid #ddd;" onchange="changeishome(this)">
            <option value="">首页</option>
            <option value="1">是</option>
            <option value="0">否</option>
          </select>
          <select name="isvouch" style="padding:5px 15px; border:1px solid #ddd;" onchange="changeisvouch(this)">
            <option value="">推荐</option>
            <option value="1">是</option>
            <option value="0">否</option>
          </select>
          <select name="istop" style="padding:5px 15px; border:1px solid #ddd;" onchange="changeistop(this)">
            <option value="">置顶</option>
            <option value="1">是</option>
            <option value="0">否</option>
          </select>
          &nbsp;&nbsp;&nbsp;
          
          移动到：
          <select name="movecid" style="padding:5px 15px; border:1px solid #ddd;" onchange="changecate(this)">
            <option value="">请选择分类</option>
            {volist name='cate' id='category'}
              <option value="{$category.cateid}">
                <?php 
                  if($category['parentsid']!==0){echo "|".str_repeat('-',$category['level']*4);} 
                ?>
                {$category.name}
              </option>
            {/volist}
          </select>
          </td>
      </tr>
      <tr>
        <td colspan="8">
          <div class="pagelist">
            <a href="{:url('Category/manage')}?page=1">首页</a>
            
            {if condition="$page-2 gt 0"}<!--显示前两页及上一页-->
            <a href="{:url('Category/manage')}?page={$page-1}">上一页</a>
              {if condition="$page-4 gt 0"}<!--当前页为最后页，为了美观前面多显示两页-->
              <a href="{:url('Category/manage')}?page={$page-4}">{$page-4}</a>
              <a href="{:url('Category/manage')}?page={$page-3}">{$page-3}</a>
              {elseif condition="$page-3 gt 0"}<!--当前页为倒数第二页，为了美观前面多显示一页-->
              <a href="{:url('Category/manage')}?page={$page-3}">{$page-3}</a>
              {/if}
            <a href="{:url('Category/manage')}?page={$page-2}">{$page-2}</a>
            <a href="{:url('Category/manage')}?page={$page-1}">{$page-1}</a>
            {elseif condition="$page-1 gt 0"}<!--显示前一页及上一页-->
            <a href="{:url('Category/manage')}?page={$page-1}">上一页</a>
            <a href="{:url('Category/manage')}?page={$page-1}">{$page-1}</a>
            {else}
            <span class="">上一页</span>
            {/if}

            <span class="current">{$page}</span>

            {if condition="$page+2 elt $pagetotal"}<!--显示后两页及下一页-->
            <a href="{:url('Category/manage')}?page={$page+1}">{$page+1}</a>
            <a href="{:url('Category/manage')}?page={$page+2}">{$page+2}</a>
              {if condition="$page eq 1 && $pagetotal egt $page+4"}<!--当前页为第一页，为了美观后面多显示两页-->
              <a href="{:url('Category/manage')}?page={$page+3}">{$page+3}</a>
              <a href="{:url('Category/manage')}?page={$page+4}">{$page+4}</a>
              {elseif condition="$page eq 1 && $pagetotal egt $page+3"}
              <a href="{:url('Category/manage')}?page={$page+3}">{$page+3}</a>
              {elseif condition="$page eq 2 && $pagetotal egt $page+3"}<!--当前页为第二页，为了美观后面多显示一页-->
              <a href="{:url('Category/manage')}?page={$page+3}">{$page+3}</a>
              {/if}
            <a href="{:url('Category/manage')}?page={$page+1}">下一页</a>
            {elseif condition="$page+1 elt $pagetotal"}<!--显示后一页及下一页-->
            <a href="{:url('Category/manage')}?page={$page+1}">{$page+1}</a>
            <a href="{:url('Category/manage')}?page={$page+1}">下一页</a>
            {else}
            <span class="">下一页</span>
            {/if}

            <a href="{:url('Category/manage')}?page={$pagetotal}">尾页</a>
            <span class=""><b style="color: red;">{$page}</b>/{$pagetotal}</span>
            <span><input id="go" style="border: 0; width: 25px;"></span>
            <a href="javascript:void(0)" onclick="return go()">GO</a>
          </div>
        </td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript">

//搜索
function changesearch(){	
		
}

//单个删除
function del($id){
	if(confirm("您确定要删除吗?")){
		window.location.href='../category/del/id/'+$id+'.html';
	}
}

//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
    document.listform.action = "../category/del";
    document.listform.method = "get"; //post
    document.listform.submit();
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

//批量排序
function sorts(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		document.listform.action = "sorts";
    document.listform.method = "get"; //post
    document.listform.submit();
	}
	else{
		alert("请选择要操作的内容!");
		return false;
	}
}


//批量首页显示
function changeishome(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		document.listform.action = "home";
    document.listform.method = "get"; //post
    document.listform.submit(); 
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}

//批量推荐
function changeisvouch(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		document.listform.action = "vouch";
    document.listform.method = "get"; //post
    document.listform.submit();	
	}
	else{
		alert("请选择要操作的内容!");	
		
		return false;
	}
}

//批量置顶
function changeistop(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		document.listform.action = "top";
    document.listform.method = "get"; //post
    document.listform.submit();
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}


//批量移动
function changecate(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		document.listform.action = "changecate";
    document.listform.method = "get"; //post
    document.listform.submit(); 
	}
	else{
		alert("请选择要操作的内容!");
		
		return false;
	}
}

//批量复制
function changecopy(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		var i = 0;
	    $("input[name='id[]']").each(function(){
	  		if (this.checked==true) {
				i++;
			}		
	    });
		if(i>1){ 
	    	alert("只能选择一条信息!");
			$(o).find("option:first").prop("selected","selected");
		}else{
		
			$("#listform").submit();		
		}	
	}
	else{
		alert("请选择要复制的内容!");
		$(o).find("option:first").prop("selected","selected");
		return false;
	}
}

</script>
</body>
</html>